<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登陆</title>
    <link rel="stylesheet" th:href="@{/common/layui/css/layui.css}">
    <script th:src="@{/common/js/jquery.min.js}" type="text/javascript"></script>

</head>
<body style="width: 100%;height: 100%; margin: 0;padding: 0;
        background-image:url('/image/background.jpg')">
<div style=" position: relative; top:200px; margin: auto;height: 300px; width: 400px; border: 1px solid; background-color: #c7ddef">
    <p style=" position: absolute; padding-left: 55px; padding-top: 40px; font-size: 20px;
        letter-spacing:10px; font-family: 黑体" >欢迎登陆我的拍卖网站</p>
    <div style="width: 95%;height: 80%;padding-top: 70px; border-color: #F2F2F2;">
        <form class="layui-form" action="" style="height:95%;width: 100%; padding-top: 25px; ">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input class="layui-input"  type="text" id="uname" name="uname" lay-verity="required" placeholder="请输入用户名" autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码框</label>
            <div class="layui-input-block">
                <input type="password" id="password" name="password" required lay-verify="required"
                       placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-primary" onclick="register()"
                        lay-submit lay-filter="formDemo">注册</button>
                <button type="button" onclick="login()" class="layui-btn">登陆</button>
            </div>
        </div>
    </form>
    </div>
</div>
</body>
<script src="../../common/layui/css/layui.css">
    layui.use(['layei','form'],function () {
       var layer = layui.layer,
           from = layui.from;
    });


</script>
<script type="text/javascript">
    function login(){
        var uname = $("#uname").val();
        var password = $("#password").val();
        if(uname == undefined || uname == "" || uname == null){
            alert("请输入用户名");
            return;
        }
        if(password == undefined || password == "" || password == null){
            alert("请输入密码");
            return;
        }
        $.ajax({
            type:"post",
            url:"/user/login",
            data:"uname="+uname+"&password="+password,
            dataType: "json",
           // contentType: "application/json; charset=utf-8",
            success:function(data) {
                console.log(data)
                if(!data.success){
                    alert(data.msg);
                    return;
                }
                window.location.href="/page/logo.do";

            },
            error: function(){
                alert("登陆失败，用户名或密码错误！！！");

            }

        });
    }

    function register() {
        window.location.href="/user/toRegister";
    }
</script>
</html>